<?php
/**
 * Created by PhpStorm.
 * User: dingxiaolin
 * Date: 2021-03-03
 * Time: 23:29
 */

namespace app\common\model;

use think\Model;
use think\Request;

//注意大小写，导入think的Model类

class Klass extends Model
{
    private $Teacher;

    /**
     * 获取对应的教师（辅导员）信息
     * @return Teacher 教师
     */
    public function getTeacher()
    {
        if (is_null($this->Teacher)) {
            //echo '执行1次<br />';
            $teacherId = $this->getData('teacher_id');
            $this->Teacher = Teacher::get($teacherId);
        }

        return $this->Teacher;
    }

    /**
     * 获取对应的教师（辅导员）信息
     * @return Teacher 教师对象
     */
    /*    public function Teacher()
        {
            //echo '执行1次<br />';
            $teacherId = $this->getData('teacher_id');
            return Teacher::get($teacherId);

        }*/
    public function Teacher()
    {
        return $this->belongsTo('teacher');
    }


}